﻿using PostSharp.Aspects;
using PostSharp.Serialization;

namespace Enterprises.Wpf.Core.AOP;

[PSerializable]
public class PointAdressAspect: OnMethodBoundaryAspect
{
    public override void OnEntry(MethodExecutionArgs args)
    {
        if (args.Method.IsSpecialName) 
        {
            string methodName = args.Method.Name;
            AOPTest instance = (AOPTest)args.Instance;
            string name= instance.Name;
            if (methodName.StartsWith("set_"))
            {
                // 这里可以添加日志逻辑
                string propertyName = methodName.Substring(4);
                Console.WriteLine($"{args.Method.Name} of {args.Instance.GetType().Name} for property {propertyName}");
            }
            else if (methodName.StartsWith("get_"))
            {
                string propertyName = methodName.Substring(4);
                Console.WriteLine($"{args.Method.Name} of {args.Instance.GetType().Name} for property {propertyName}");
            }
        }
    }
}